var prefix = ctx + "module/order"

$(function() {
	var columns = [{
            checkbox: true
        },
				{
			field : 'order.orderId', 
			title : '序号' 
		},
				{
			field : 'order.orderNum', 
			title : '订单号' 
		},
				{
			field : 'order.fullName', 
			title : '产品' 
		},
				{
			field : 'order.typeName', 
			title : '产品名称' 
		},
				{
			field : 'productInfo.productPrice', 
			title : '金额' 
		},
				{
			field : 'customerInfo.name', 
			title : '客户' 
		},
				{
			field : 'order.salesUserName', 
			title : '业务员' 
		},
				{
			field : 'order.auditStatus', 
			title : '审批状态' ,
			formatter: function(value, row, index) {
                if (value == 0) {
                	return '<span class="label label-primary">未审核</span>';
                } else if (value == 1) {
                	return '<span class="label label-primary">审核中</span>';	
                }else if (value == 2) {
                	return '<span class="label label-success">审核通过</span>';                	
                }else if (value == 3) {
                	return '<span class="label label-danger">审核被拒</span>';                	
                }
            }
		},
				{
			field : 'dealTime', 
			title : '结单时间' 
		},
		        {
            title: '操作',
            align: 'center',
            formatter: function(value, row, index) {
            	var actions = [];
				actions.push('<a class="btn btn-primary btn-sm ' + editFlag + '" href="#" title="处理" mce_href="#" onclick="edit(\'' + row.orderId + '\')"><i class="fa fa-hand-pointer-o"></i></a> ');
				return actions.join('');
            }
        }];
	var url = prefix + "/list";
	$.initTable(columns, url);
});

/*订单-新增*/
function add() {
    var url = prefix + '/add';
    layer_showAuto("新增订单", url);
}

/*订单-修改*/
function edit(orderId) {
    var url = prefix + '/edit/' + orderId;
    layer_showAuto("订单详情", url);
}
